package ecoll.client.dictionary;

import java.io.Serializable;
import java.util.ArrayList;

@SuppressWarnings("serial")
public class Definition implements Serializable {

	private String word;
	private int wordClass;
	private ArrayList<String> synonyms;
	private String meaning;

	static final String[] classes = new String[] { "unknown", "adjective",
			"adverb", "noun", "verb", "preposition" };

	static final String[] shortClasses = new String[] { "?", "adj.", "adv.",
			"n.", "v.", "prep." };

	public Definition() {
	}

	public Definition(String word, String wordClass,
			ArrayList<String> synonyms, String meaning) {
		setWord(word);
		setWordClass(wordClass);
		setSynonyms(synonyms);
		setMeaning(meaning);
	}

	public String getWord() {
		return word;
	}

	public void setWord(String word) {
		this.word = word.toLowerCase();
	}

	public String getWordClass() {
		return classes[wordClass];
	}

	public String getShortClass() {
		return shortClasses[wordClass];
	}

	public void setWordClass(String wordClass) {
		wordClass = wordClass.toLowerCase();
		this.wordClass = 0;
		for (int i = 1; i < classes.length; ++i)
			if (wordClass.equals(classes[i]))
				this.wordClass = i;
	}

	public ArrayList<String> getSynonyms() {
		return synonyms;
	}

	public void setSynonyms(ArrayList<String> synonyms) {
		this.synonyms = synonyms;
	}

	public String getMeaning() {
		return meaning;
	}

	public void setMeaning(String meaning) {
		this.meaning = meaning;
	}

}
